package ua.kpi.flats.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.springframework.format.annotation.DateTimeFormat;

import ua.kpi.flats.entity.enums.MeetingStatus;
import ua.kpi.flats.util.JsonDateAndTimeSerializer;

@Entity
@JsonAutoDetect
@Table(name = "MEETING")
public class Meeting implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name = "MEETINGID")
	@GeneratedValue(strategy = GenerationType.AUTO)
	private long id;
	
	@NotNull
	@DateTimeFormat(pattern = "HH:mm MM/dd/yyyy")
	@Column(name = "ONDATE")
	private Date date;
	
	@Enumerated(value = EnumType.STRING)
	@Column(name = "STATUS")
	private MeetingStatus status;
	
	@NotNull
	@ManyToOne
	@JoinColumn(name = "OPTIONSID")
	private SuitableOption option;
	
	public Meeting() {
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	@JsonSerialize(using=JsonDateAndTimeSerializer.class)
	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public MeetingStatus getStatus() {
		return status;
	}

	public void setStatus(MeetingStatus status) {
		this.status = status;
	}

	public SuitableOption getOption() {
		return option;
	}

	public void setOption(SuitableOption option) {
		this.option = option;
	}
}
